<template>
	<view class="">
		<view class="scan_code">
			<view class="scan_code_info" @click="OnScan">
				<image src="https://t1.chowtaiking.com.cn/img/ruoyi/2025/03/10/9a37348ec4264917acc8d38838ce2197.png" mode="widthFix"></image>
				<view class="">扫码核销</view>
			</view>
		</view>
		<view class="scan_code_list">
			<view class="scan_code_item" @click="Onmy_order">
				<image src="https://t1.chowtaiking.com.cn/img/ruoyi/2025/03/10/d72855c3a27a451fb639cfbc14516871.png" mode="widthFix"></image>
				<view class="">我的订单</view>
			</view>
		</view>
		<!-- <view class="scan_code">
			<view class="scan_code_search">
				<view class="scan_code_input">
					<input type="number" placeholder="请输入平台订单编号" v-model="barcode" />
				</view>
				<view class="scan_code_icon" @click="OnScan()">
					
				</view>
			</view>
			<view class="code_list">
				<view class="code_record">核销记录</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
				<view class="code_item">1212123654789652</view>
			</view>
			<view class="code_btn">
				<button>提交</button>
			</view>
		</view> -->
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				barcode: '',
				code_list: [],
				status: 'xj',
				entryTime:0,
			}
		},
		onLoad(params) {
			if(typeof(params)!='undefined'){
				var numberId = params.numberId || '';
				if(numberId != ''){
					uni.clearStorageSync();
					app.globalData.data.numberId = numberId;
				}
			}
			this.init();
		},
		onShow() {
			// 记录用户进来时间
			this.entryTime = Date.now();
		},
		onUnload() {
			this.OnEntryTime();
		},
		methods: {
			init(e) {
				var user = app.globalData.get_user_info(this, "init", "");
				if (user != false) {
					// 用户未绑定用户则转到登录页面
					if (app.globalData.user_is_need_login(user)) {
						uni.navigateTo({
							url:"/pages/login/login?event_callback=onLoad"
						})
					} else {
						// this.get_data();
					}
				}
			},
			OnEntryTime(){
				var radarlog_data = {
					pageUrl:"pages/manage/update_stu/diamond_scan_cancel/diamond_scan_cancel",
					name:"钻石产品核销",
					remark:"钻石产品核销停留时间",
					entryTime:this.entryTime,
				}
				uni.request({
					url:app.globalData.get_request_url("radarlog/add"),
					data:radarlog_data,
					method:"POST",
					success: (res) => {
						console.log(res,"钻石产品核销停留时间");
					}
				})
			},
			// 二维码扫描
			OnScan() {
				uni.scanCode({
					scanType: ['barCode', 'qrCode'],
					success: function(res) {
						console.log(res, "res");
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						this.barcode = res.result;
						// this.get_data(this.barcode);
					}
				});
			},
			// 跳转我的订单
			Onmy_order(){
				uni.navigateTo({
					url:"/pages/user-order/user-order"
				})
			},
			get_data() {
				uni.request({
					url:app.globalData.data.request_admin_url + 'gold/storeProduct/update_stu/',
					method: 'POST',
					data: {
						barCodes:['zb8654466']
					},
					header: {
						'Authorization': 'Bearer ' + app.globalData.data.admin_token
					},
					success: (res) => {
						
						console.log(res);
					}
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f2f2f2;
	}

	.active {
		background-color: red !important;
		color: white;
	}
	.scan_code{
		width: 300rpx;
		height: 300rpx;
		position: relative;
		margin: 120rpx auto;
		background-color: aqua;
		border-radius: 50%;
		.scan_code_info{
			position: absolute;
			left: 30%;
			top: 30%;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			image{
				width: 60rpx;
				padding-bottom: 10rpx;
			}
		}
	}
	.scan_code_list{
		width: 60%;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 20%;
		.scan_code_item{
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 13px;
			image{
				width: 60rpx;
			}
		}
	}
</style>